package com.woniuxy.controller;

import com.woniuxy.controller.entity.User;
import org.springframework.web.bind.annotation.*;

@RestController //通常是用于restful风格写法的
public class UserRestFulController {

    @RequestMapping(value = "/user",method = RequestMethod.POST)
    public String addUser(@RequestBody User user){
        System.out.println("UserRestFulController.addUser方法执行！");
        return user.toString();
    }

    @DeleteMapping("/user/{id}/{userid}/{myname}")
    public String deleteUser(@PathVariable("userid") int id,@PathVariable("id") int userid,@PathVariable String myname){
        System.out.println("UserRestFulController.deleteUser执行");
        return id+"--"+userid+"---"+myname;
    }

    @DeleteMapping("/user/{id}/{myname}")
    public String deleteUser(@PathVariable("id") int id,@PathVariable String myname){
        System.out.println("UserRestFulController.deleteUser执行");
        return id+"--"+"---"+myname;
    }
    @PutMapping("/user")
    public String updateUser(@RequestBody User user){
        System.out.println("UserRestFulController.updateUser执行");
        return user.toString();
    }
    @GetMapping("/user/{id}")
    public String findUser(@PathVariable("id") int userid){
        System.out.println("UserRestFulController.findUser执行："+userid);
        User user = new User(userid+"",userid);
        return user.toString();
    }
}
